/*
 * 编程计算a+aa+aaa+…+aa…a（n个a）的值（4分）
 */

#include <stdio.h>

int main() {
	setbuf(stdout, NULL);

	int a, n;
	long temp, sum = 0;

	printf("Input a,n:\n");
	scanf("%d,%d", &a, &n);

	temp = a;
	for (int i = 0; i < n; ++i) {
		// STEP: 计算该轮的temp
		for (int j = 0; j < i; ++j) {
			temp = temp * 10 + a;
		}

		// STEP: 将该轮的temp交付给sum
		sum += temp;

		// STEP: temp重新初始化
		temp = a;
	}

	printf("sum=%ld\n", sum);

	return 0;
}
